﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VSDBM.Code.dao;

public partial class Visual_Messages_readmessage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                String cod = Session["idselectmessage"].ToString();
                VSDBM.Code.dto.Message objeto = MessageDAO.DStoList(MessageDAO.select(false, "WHERE id=" + cod, ""))[0];
                tbtitle.Text = objeto.title;
                tbmessage.Text = objeto.message;
                tbdate.Text = objeto.date;
                tbuser.Text = UserDAO.DStoList(UserDAO.select(false, " WHERE id = " + objeto.touserid, ""))[0].name;
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.Message);
            }
        }
    }

    protected void btgo_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("inbox.aspx");
    }

    protected void btdelete_onclick(object sender, ImageClickEventArgs e)
    {
        MessageDAO.deleteid(int.Parse(Session["idselectmessage"].ToString()));
        Response.Redirect("inbox.aspx");
    }
}